USE [Clinic]
GO
/******    ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[up_SugarProfileInsert]
		  @SugarProfileID int
		, @Date datetime
		, @HourSmallID smallint
		, @BloodSugar nvarchar(50)
		, @Quantity nvarchar(50)
		, @HoursBigID smallint
		, @SugarConsistence nvarchar(50)
		, @patientID int
AS
BEGIN
	SET NOCOUNT ON;
	INSERT INTO [SugarProfile]
	(
		  [Date]
		, [HourSmallID]
		, [BloodSugar]
		, [Quantity]
		, [HoursBigID]
		, [SugarConsistence]
		, [patientID]
	) 
	VALUES 
	(
		  @Date
		, @HourSmallID
		, @BloodSugar 
		, @Quantity 
		, @HoursBigID
		, @SugarConsistence 
		, @patientID
	)		
END

/******    ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[up_SugarProfileDelete]
	  @SugarProfileID int
	
AS
BEGIN
	SET NOCOUNT ON;
	DELETE FROM [SugarProfile]
	WHERE [SugarProfileID] = @SugarProfileID
END

/******    ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[up_SugarProfileUpdate]
		  @SugarProfileID int
		, @Date datetime
		, @HourSmallID smallint
		, @BloodSugar nvarchar(50)
		, @Quantity nvarchar(50)
		, @HoursBigID smallint
		, @SugarConsistence nvarchar(50)
		, @patientID int
AS
BEGIN
	SET NOCOUNT ON;
	UPDATE [SugarProfile]
	SET 
		  [Date] = @Date
		, [HourSmallID] = @HourSmallID
		, [BloodSugar] = @BloodSugar
		, [Quantity] = @Quantity
		, [HoursBigID] = @HoursBigID
		, [SugarConsistence] = @SugarConsistence
		, [patientID] = @patientID
	WHERE 
		[SugarProfileID] = @SugarProfileID
END

/******    ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[up_SugarProfileGetAllByPatientID]
	  @PatientID int
	
AS
BEGIN
	SET NOCOUNT ON;
	SELECT *
	FROM [SugarProfile]
	WHERE 
			[PatientID] = @PatientID
END